package org.peterf.foxish.texture;

import android.util.Log;

public class SlicedTexture extends Texture {

    private int cellHeight;

    private int cellWidth;

    private int countX;

    private int countY;

    public SlicedTexture(Texture texture, int countX, int countY) {
        super(texture);
        this.countX = countX;
        this.countY = countY;
        cellWidth = width / countX;
        cellHeight = height / countY;
    }

    public int getCellHeight() {
        return cellHeight;
    }

    public int getCellWidth() {
        return cellWidth;
    }

    public int getCountX() {
        return countX;
    }

    public int getCountY() {
        return countY;
    }

    public void getTextureCoordinate(float st[], int offset, int stride, int x, int y) {
        if (stride == 0) {
            stride = 2;
        }
        st[offset] = 1.0f / countX * x;
        st[offset + 1] = 1.0f / countY * y;
        offset += stride;
        st[offset] = 1.0f / countX * x;
        st[offset + 1] = 1.0f / countY * (y + 1);
        offset += stride;
        st[offset] = 1.0f / countX * (x + 1);
        st[offset + 1] = 1.0f / countY * y;
        offset += stride;
        st[offset] = 1.0f / countX * (x + 1);
        st[offset + 1] = 1.0f / countY * (y + 1);
    }

}
